package com.harmony.pilot.knowledge.entity;

import lombok.Data;
import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * Include依赖关系实体
 * 记录头文件包含关系
 */
@Data
@Entity
@Table(name = "include_dependency", indexes = {
    @Index(name = "idx_file_path", columnList = "file_path"),
    @Index(name = "idx_include_path", columnList = "include_path"),
    @Index(name = "idx_resolved_path", columnList = "resolved_path")
})
public class IncludeDependency {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /** 源文件路径（.h/.cpp文件） */
    @Column(name = "file_path", nullable = false, length = 1000)
    private String filePath;
    
    /** include路径 (如 "base/utils.h" 或 "foundation/arkui/napi/napi_common.h") */
    @Column(name = "include_path", nullable = false, length = 1000)
    private String includePath;
    
    /** include语句完整内容 */
    @Column(name = "include_statement", length = 1000)
    private String includeStatement;
    
    /** include类型：SYSTEM/LOCAL/RELATIVE */
    @Column(name = "include_type", length = 20)
    private String includeType;
    
    /** include语句行号 */
    @Column(name = "line_number")
    private Integer lineNumber;
    
    /** 是否解析成功（找到实际文件） */
    @Column(name = "resolved")
    private Boolean resolved = false;
    
    /** 解析后的实际头文件路径 */
    @Column(name = "resolved_path", length = 1000)
    private String resolvedPath;
    
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;
    
    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
    }
}

